<?php

namespace App\Models\User;

use App\Models\User\Users;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Casts\Attribute;

class UserDetail extends Model
{
    public $timestamps = false;
    protected $guarded = [];
    protected $table = "user_detail";

    protected function age(): Attribute
    {
        return new Attribute(
            get: fn($value, $attributes) => date("Y", time()) - intval(substr($attributes['birthday'], 0, 4)),
        );
    }

    public function users()
    {
        return $this->hasOne(Users::class, 'id', 'id');
    }
}
